<template>
	<view class="container-robot" style="background: url(/static/imgbgc3.png) no-repeat; background-size: 100%">
		<u-navbar
			title=""
			:placeholder="true"
			:autoBack="true"
			bgColor="transparent"
		>
		</u-navbar>
		<view class="main">
			<view class="item-robot flex" v-for="(item,index) in list" :key="item.id">
				<view class="lt" :class="type==1?'lt1':''">
					<image :src="$fun.imgUrl(item.image)" mode=""></image>
				</view>
				<view class="rt" v-if="type==1">
					<view class="title">{{item.name}}</view>
					<view class="name2">{{$t('panel.name30')}}：{{item.period}}{{$t('panel.name19')}} {{$t('panel.name28')}}：{{item.property}}</view>
					<view class="name1"></view>
					<view class="name2">{{$t('panel.name25')}}：{{$t('panel.name2')}}</view>
					<view class="flex-between">
						<text class="price">{{item.price}}</text>
						<view class="">
							<u-button type="primary" :text="$t('user.name71')" shape="circle" style="width: 160rpx;"
								color="#00A3FF" size="small" @click="handleNext(item)"></u-button>
						</view>
					</view>
				</view>
				<view class="rt" v-else>
					<view class="title">{{item.name}}</view>
					<view class="">{{$t('vnode.name22')}}：{{item.balance}}{{$t('vnode.name23')}}</view>
					<view class="flex-between">
						<!-- <text class="price">{{item.min_money}}~{{item.mx_money}}</text> -->
						<text class="price">{{item.price}}</text>
						<view class="">
							<u-button type="primary" :text="$t('vnode.name14')" shape="circle" style="width: 160rpx;"
								color="#00A3FF" size="small" @click="handleNext(item)"></u-button>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-popup :show="show" @close="close" closeable>
			<view class="popup-box">
				<view class="title">
					{{$t('vnode.name15')}}
				</view>
				<view class="input flex">
					<view class="">
						{{$t('vnode.name16')}}:
					</view>
					<input type="text" v-model="money" :placeholder="$t('vnode.name17')" />
				</view>
				<view class="text">
					{{$t('vnode.name18')}}：{{model.min_money}}~{{model.mx_money}}
				</view>
				<view class="btn">
					<u-button type="primary" :text="$t('vnode.name19')" shape="circle" @click="handleNext"></u-button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				show: false,
				model: {},
				money: '',
				type: ''
			};
		},
		onLoad(option) {
			this.type=option.type
			this.getProductList()
		},
		methods: {
			// 获取机器人列表
			async getProductList() {
				const res = await this.$fun.ajax.post('product/productList',{
						type: this.type
					})
				this.list = res.data
			},
			close() {
				this.show = false
				this.model = {}
				this.money = ''
			},
			handleNext(val) {
				this.model = val
				this.money=val.price
				
				this.$fun.jump(
					`/pageC/robotPay/robotPay?id=${this.model.id}&url=${this.model.image}&money=${this.money}&name=${this.model.name}&type=${this.type}`
					)
			},
			async handlePay(val) {
				this.show = true
				this.model = val
				// this.$fun.jump(`/pageC/robotPay/robotPay?id=${val.id}&url=${val.image}&money=${val.money}&name=${val.name}`)
				// const res = await this.$fun.ajax.post('product/productList')
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.container-robot {
		height: 100%;

		.popup-box {
			height: 500rpx;
			padding: 0 30rpx;

			.title {
				text-align: center;
				padding: 20rpx 0;
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #232323;

			}

			.input {
				margin-top: 80rpx;
				padding: 20rpx 0;
				border-bottom: 1rpx solid #d9d9d9;
			}

			.text {
				font-size: 24rpx;
				color: #b9b9b9;
			}

			.btn {
				margin-top: 80rpx;
			}
		}

		.main {
			padding: 30rpx;

			.item-robot {
				// height: 190rpx;
				background-color: rgba(255, 255, 255, 0.7);
				border-radius: 20rpx;
				padding: 10rpx 30rpx;
				margin: 20rpx 0;

				.lt {
					width: 128rpx;
					height: 100%;
					height: 190rpx;
					margin-right: 20rpx;

				}
				.lt1{
					width: 128rpx;
					height: 128rpx;
				}
				.rt {
					flex: 1;
					
					& view:nth-child(1) {
						font-family: PingFang SC, PingFang SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #232323;
						line-height: 38rpx;
					}

					& view:nth-child(2) {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #939393;
					}
					.name1{
						font-weight: 400;
						font-size: 22rpx;
						color: #939393;
					}
					.name2{
						font-weight: 400;
						font-size: 20rpx;
						color: #595959;
						margin-top: 8rpx;
					}
					.price {
						font-family: DIN, DIN;
						font-weight: bold;
						font-size: 28rpx;
						color: #FF4201;
						line-height: 56rpx;
					}
				}
			}
		}
	}
</style>